package com.hytc.mymall.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hytc.mymall.R;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Joker on 2016/12/1.
 */

public class SelectPopAdapter extends BaseAdapter
{
    private Context context;
    private List<String> list;
    private Map<Integer, View> lmap;
    private boolean screenwidth;

    public SelectPopAdapter(final Context context, final List<String> list, final boolean screenwidth) {
        this.lmap = new HashMap<Integer, View>();
        this.context = context;
        this.list = list;
        this.screenwidth = screenwidth;
    }

    public int getCount() {
        return this.list.size();
    }

    public Object getItem(final int n) {
        return null;
    }

    public long getItemId(final int n) {
        return 0L;
    }

    public View getView(final int n, final View view, final ViewGroup viewGroup) {
        View inflate;
        ViewHolder tag;
        if (this.lmap.get(n) != null) {
            inflate = this.lmap.get(n);
            tag = (ViewHolder)inflate.getTag();
        }
        else {
            inflate = View.inflate(this.context, R.layout.item_selectpop, (ViewGroup)null);
            tag = new ViewHolder();
            tag.tv = (TextView)inflate.findViewById(R.id.tv_item);
            inflate.setTag((Object)tag);
        }
        if (!this.screenwidth) {
            tag.tv.setTextColor(-1);
        }
        tag.tv.setText((CharSequence)this.list.get(n));
        return inflate;
    }

    private class ViewHolder
    {
        public TextView tv;
    }
}
